<include file="public@header" />
</head>
<style type="text/css">
    .file-wrap{
        height:34px;
        width: 82px;
        position: relative;
        display: inline-block;
        text-align: center;
        line-height: 34px;
        overflow: hidden;
        font-size: 14px;
        cursor: pointer;
        color: #fff;
        vertical-align: middle;
        background-color: #1a242f;
        border-color: #161f29;
    }
    .file-wrap input{
        position: absolute;
        height: 40px;
        z-index: 2;
        right: 0;
        top: 0;
        filter: alpha(opacity=0);
        -moz-opacity: 0;
        opacity: 0;
        cursor: pointer;
        font-size: 16px;
    }
</style>
<body>
<div class="wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('star/index')}">明星列表</a></li>
        <li><a href="{:url('star/add')}">明星添加</a></li>
        <li class="active"><a>账户扣款</a></li>
    </ul>
    <form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('star/deductionPost')}">
        <div class="form-group">
            <label for="input-s_name" class="col-sm-2 control-label"><span class="form-required">*</span>姓名</label>
            <div class="col-md-6 col-sm-10">
                <input type="hidden" name="d_udid" value="{$star.s_udid}">
                <input type="text" class="form-control" id="input-s_name" value="{$star.s_name}" disabled>
            </div>
        </div>
        <div class="form-group">
            <label for="input-d_name" class="col-sm-2 control-label"><span class="form-required">*</span>银行名称</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" id="input-d_name" name="d_name">
            </div>
        </div>
        <div class="form-group">
            <label for="input-d_account" class="col-sm-2 control-label"><span class="form-required">*</span>银行账号</label>
            <div class="col-md-6 col-sm-10">
                <input type="number" class="form-control" id="input-d_account" name="d_account">
            </div>
        </div>
        <div class="form-group">
            <label for="input-d_phone" class="col-sm-2 control-label"><span class="form-required">*</span>联系人手机</label>
            <div class="col-md-6 col-sm-10">
                <input type="number" class="form-control" id="input-d_phone" name="d_phone">
            </div>
        </div>
        <div class="form-group">
            <label for="input-d_amount" class="col-sm-2 control-label"><span class="form-required">*</span>扣款金额(分)</label>
            <div class="col-md-6 col-sm-10">
                <input type="number" class="form-control" id="input-d_amount" name="d_amount">
            </div>
        </div>
        <div class="form-group">
            <label for="input-s_image" class="col-sm-2 control-label"><span class="form-required">*</span>打款截图</label>
            <div class="col-md-6 col-sm-10">
                <img src="__TMPL__/public/assets/images/default-thumbnail.png" id="img" width="128" style="cursor: pointer"/>
                <div id="file-wrap" class="file-wrap">
                    <input type="file" onchange="upload(this)" accept="image/jpg,image/jpeg,image/png" id="input-s_image" name="file" style="display: inline"/>
                    选择图片
                </div>
                <input type="button" class="btn btn-default" id="cancel_img" onclick="cancel();" value="取消图片" style="display: none">
                <input type="hidden" name="path" id="path" value="">
                <input type="hidden" name="file" id="file" value="">
                <p class="help-block">头像支持jpg,png,jpeg格式,文件大小最大不能超过1M</p>
            </div>
        </div>
        <div class="form-group">
            <label for="input-d_description" class="col-sm-2 control-label"><span class="form-required"></span>备注</label>
            <div class="col-md-6 col-sm-10">
                <textarea class="form-control" id="input-d_description"  name="d_description" ></textarea>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary js-ajax-submit">提交</button>
            </div>
        </div>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script type="application/javascript">

    function cancel() {
        $('#file-wrap').show();
        $('#input-s_image').val('').attr('style','display: inline');
        $('#img').attr('src',"__TMPL__/public/assets/images/default-thumbnail.png");
        $('#cancel_img').attr('style','display: none');
        $('#pat').attr('value','');
        $('#file').attr('value','');
    }
    function upload(obj) {
        var $fileinput = $(obj);
        Wind.css("jcrop");
        Wind.use("ajaxfileupload", "jcrop", "noty", function () {
            $.ajaxFileUpload({
                url: "{:url('star/uploadImg')}",
                secureuri: false,
                fileElementId: "input-s_image",
                dataType: 'json',
                data: {},
                success: function (data, status) {
                    if (data.code) {
                        $("#file-wrap").hide();
                        $('#cancel_img').show();
                        var src  = '{$simgs}'+ data.data.path + data.data.file;
                        $('#img').attr('src',src);
                        $('#path').attr('value',data.data.path);
                        $('#file').attr('value',data.data.file);
                    } else {
                        noty({
                            text: data.msg,
                            type: 'error',
                            layout: 'center',
                            callback: {
                                afterClose: function () {
                                    reloadPage(window);
                                }
                            }
                        });
                        cancel();
                    }
                },
                error: function (data, status, e) {
                    cancel();
                    alert(e + '\r选择的图片文件错误。请重新选择！');
                }
            });
        });
        return false;
    }

</script>
</body>
</html>
